package web.sso.http.process;

import org.springframework.core.MethodParameter;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import web.sso.http.annotation.framework.HttpParam;

/**
 * DATE: 2020/1/21
 * TIME: 6:49 下午
 *
 * @author：huangliming
 */
public class HttpParamProcess extends HttpAnnotationProcess {

    @Override
    public String getAnnotationParameterName(MethodParameter methodParameter) {
        return methodParameter.getParameterAnnotation(HttpParam.class).value();
    }

    @Override
    public Mono<MultiValueMap<String, String>> getParameterMap(ServerWebExchange serverWebExchange) {
        return Mono.just(serverWebExchange.getRequest().getQueryParams());
    }

    @Override
    public boolean supportsParameter(MethodParameter methodParameter) {
        return methodParameter.hasParameterAnnotation(HttpParam.class);
    }
}
